<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:ui="clr-namespace:Mvvm.UI"
    xmlns:wpfPredefinedToastNotifications="clr-namespace:Mvvm.UI.Services.NotificationService.WpfPredefinedToastNotifications"
    xmlns:dxmvvmi="clr-namespace:Mvvm.UI.Services.NotificationService.CustomToastNotifications">

    <DataTemplate x:Key="DefaultCustomToastTemplate">
        <Border Background="#FC972E">
            <TextBlock Text="{Binding}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
        </Border>
    </DataTemplate>

    <DataTemplate x:Key="PredefinedToastTemplate">
        <Grid>
            <Grid.Resources>
                <ui:ObjectToObjectConverter x:Key="ObjectToVisibilityConverter" DefaultTarget="Visible">
                    <ui:MapItem Source="{x:Null}" Target="Collapsed"/>
                </ui:ObjectToObjectConverter>
                <Style x:Key="LineStyle" TargetType="TextBlock">
                    <Setter Property="FontSize" Value="15"/>
                    <Setter Property="Foreground" Value="White"/>
                    <Setter Property="TextWrapping" Value="Wrap"/>
                    <Setter Property="TextTrimming" Value="CharacterEllipsis"/>
                    <Setter Property="LineStackingStrategy" Value="BlockLineHeight"/>
                    <Setter Property="LineHeight" Value="20"/>
                    <Setter Property="FontStretch" Value="Condensed"/>
                </Style>
                <DataTemplate x:Key="SimpleTemplate">
                    <TextBlock Height="60" Style="{StaticResource LineStyle}" Text="{Binding Text1}"/>
                </DataTemplate>
                <DataTemplate x:Key="OneLineHeaderTemplate">
                    <StackPanel>
                        <TextBlock Height="20" Style="{StaticResource LineStyle}" Text="{Binding Text1}" FontWeight="SemiBold"/>
                        <TextBlock Height="40" Style="{StaticResource LineStyle}" Text="{Binding Text2}"/>
                    </StackPanel>
                </DataTemplate>
                <DataTemplate x:Key="TwoLineHeaderTemplate">
                    <StackPanel>
                        <TextBlock Height="40" Style="{StaticResource LineStyle}" Text="{Binding Text1}" FontWeight="SemiBold"/>
                        <TextBlock Height="20" Style="{StaticResource LineStyle}" Text="{Binding Text2}"/>
                    </StackPanel>
                </DataTemplate>
                <DataTemplate x:Key="OneLineHeaderTwoLinesBodyTemplate">
                    <StackPanel>
                        <TextBlock Height="20" Style="{StaticResource LineStyle}" Text="{Binding Text1}" FontWeight="SemiBold"/>
                        <TextBlock Height="20" Style="{StaticResource LineStyle}" Text="{Binding Text2}"/>
                        <TextBlock Height="20" Style="{StaticResource LineStyle}" Text="{Binding Text3}"/>
                    </StackPanel>
                </DataTemplate>
                <wpfPredefinedToastNotifications:ToastTemplateSelector x:Key="ToastTemplateSelector"
                                                   SimpleTemplate="{StaticResource SimpleTemplate}"
                                                   OneLineHeaderTemplate="{StaticResource OneLineHeaderTemplate}"
                                                   TwoLineHeaderTemplate="{StaticResource TwoLineHeaderTemplate}"
                                                   OneLineHeaderTwoLinesBodyTemplate="{StaticResource OneLineHeaderTwoLinesBodyTemplate}"/>
            </Grid.Resources>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Border Grid.ColumnSpan="2">
                <Border.Background>
                    <SolidColorBrush Color="{Binding BackgroundColor}"/>
                </Border.Background>
            </Border>
            <Image Source="{Binding Image}" Width="90" Height="90" Margin="0,0,-10,0" Visibility="{Binding Image, Converter={StaticResource ObjectToVisibilityConverter}}"/>
            <ContentControl Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top" Content="{Binding}" ContentTemplateSelector="{StaticResource ToastTemplateSelector}" Margin="20,14,65,0"/>
            <Image Grid.Column="1" Source="{Binding Icon}" Margin="20,15" Width="30" Height="25" Stretch="Uniform" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
            <Border Grid.ColumnSpan="2" BorderBrush="#33F0F0F0" BorderThickness="2"/>
        </Grid>
    </DataTemplate>

    <Style TargetType="{x:Type dxmvvmi:ToastContentControl}">
        <Setter Property="Command" Value="{Binding Path=ActivateCommand, RelativeSource={RelativeSource Self}}"/>
        <Setter Property="Width" Value="385"/>
        <Setter Property="Height" Value="90"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="dxmvvmi:ToastContentControl">
                    <ControlTemplate.Resources>
                        <ui:ObjectToObjectConverter
                        x:Key="ObjectToVisibilityConverter" DefaultTarget="Visible">
                            <ui:MapItem
                        Source="{x:Null}" Target="Collapsed"/>
                        </ui:ObjectToObjectConverter>
                        <ControlTemplate x:Key="CloseButtonTemplate" TargetType="{x:Type Button}">
                            <Grid>
                                <Border x:Name="background" Opacity="0" Background="#FFFDFDFD"/>
                                <Border x:Name="border" SnapsToDevicePixels="true">
                                    <Canvas Width="10" Height="10" Margin="1,1,0,0" HorizontalAlignment="Center" VerticalAlignment="Center">
                                        <Line x:Name="line1" X1="0" Y1="0"
                       X2="9.5" Y2="9.5"
                       Stroke="White"
                       StrokeThickness="2"/>
                                        <Line x:Name="line2" X1="0" Y1="9.5"
                       X2="9.5" Y2="0"
                       Stroke="White"
                       StrokeThickness="2"/>
                                    </Canvas>
                                </Border>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="true">
                                    <Setter Property="Opacity" TargetName="background" Value="0.13"/>
                                </Trigger>
                                <Trigger Property="IsPressed" Value="true">
                                    <Setter Property="Opacity" TargetName="background" Value="1"/>
                                    <Setter Property="Stroke" TargetName="line1" Value="Black"/>
                                    <Setter Property="Stroke" TargetName="line2" Value="Black"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </ControlTemplate.Resources>
                    <Grid x:Name="root">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Appeared">
                                    <Storyboard>
                                        <DoubleAnimation x:Name="PART_AppearedAnimation1" Storyboard.TargetName="root"
                                                 Storyboard.TargetProperty="Opacity"
                                                 From="0" To="1"/>
                                        <DoubleAnimation x:Name="PART_AppearedAnimation2" Storyboard.TargetName="root"
                                                 Storyboard.TargetProperty="RenderTransform.Children[1].X"
                                                 From="385" To="0">
                                            <DoubleAnimation.EasingFunction>
                                                <ExponentialEase Exponent="5"/>
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Normal">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="dismissButton"
                                                 Storyboard.TargetProperty="Opacity"
                                                 To="0.0" Duration="0:0:0.3"/>
                                        <DoubleAnimation Storyboard.TargetName="root"
                                                 Storyboard.TargetProperty="RenderTransform.Children[0].ScaleX"
                                                 To="1" Duration="0:0:0.2"/>
                                        <DoubleAnimation Storyboard.TargetName="root"
                                                 Storyboard.TargetProperty="RenderTransform.Children[0].ScaleY"
                                                 To="1" Duration="0:0:0.2"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <BooleanAnimationUsingKeyFrames Storyboard.TargetName="selfWrapper"
                                                                        Storyboard.TargetProperty="Tag.TimerPaused">
                                            <DiscreteBooleanKeyFrame Value="True" KeyTime="0" />
                                        </BooleanAnimationUsingKeyFrames>
                                        <DoubleAnimation Storyboard.TargetName="dismissButton"
                                                 Storyboard.TargetProperty="Opacity"
                                                 To="1.0" Duration="0:0:0.3"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <BooleanAnimationUsingKeyFrames Storyboard.TargetName="selfWrapper"
                                                                        Storyboard.TargetProperty="Tag.TimerPaused">
                                            <DiscreteBooleanKeyFrame Value="True" KeyTime="0" />
                                        </BooleanAnimationUsingKeyFrames>
                                        <DoubleAnimation Storyboard.TargetName="root"
                                                 Storyboard.TargetProperty="RenderTransform.Children[0].ScaleX"
                                                 To="0.9" Duration="0:0:0.15"/>
                                        <DoubleAnimation Storyboard.TargetName="root"
                                                 Storyboard.TargetProperty="RenderTransform.Children[0].ScaleY"
                                                 To="0.9" Duration="0:0:0.15"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Activated">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="root"
                                                 Storyboard.TargetProperty="RenderTransform.Children[1].X"
                                                 To="385" Duration="0:0:0.3">
                                            <DoubleAnimation.EasingFunction>
                                                <ExponentialEase Exponent="5"/>
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Dismissed">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="root"
                                                 Storyboard.TargetProperty="RenderTransform.Children[1].X"
                                                 To="385" Duration="0:0:0.3">
                                            <DoubleAnimation.EasingFunction>
                                                <ExponentialEase Exponent="5"/>
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="TimedOut">
                                    <Storyboard>
                                        <DoubleAnimation x:Name="PART_TimedOutAnimation" Storyboard.TargetName="root"
                                                 Storyboard.TargetProperty="Opacity"
                                                 To="0"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform ScaleX="1" ScaleY="1" CenterX="192.5" CenterY="45"/>
                                <TranslateTransform/>
                            </TransformGroup>
                        </Grid.RenderTransform>
                        <Border x:Name="selfWrapper" Tag="{Binding RelativeSource={RelativeSource TemplatedParent}}"/>
                        <ContentPresenter/>
                        <Button Template="{StaticResource CloseButtonTemplate}" x:Name="dismissButton" Opacity="0" Command="{Binding Path=DismissCommand, RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Right" VerticalAlignment="Top" Width="30" Height="30"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>